package puntaelena.facilitylocation.hillclimbing.experiment.grszcompetitive;

import puntaelena.facilitylocation.hillclimbing.experiment.observeneighbors.VariateNeighborsCountReportageData;
import puntaelena.facilitylocation.hillclimbing.solver.PEHillClimbingAlgorithmBuilder;
import laboratoryQ.LaboratoryQFront;
import laboratoryQ.experiment.reportage.IReportageData;
import laboratoryQ.experiment.reportage.ui.diagram2component.IDiagramsExtractor;
import laboratoryQ.experiment.reportage.ui.diagram2component.ITitlesExtractor;
import laboratoryQ.experiment.settings.ISettingsContainer;
import laboratoryQ.experiment.settings.ReflectionBasedSettingsContainer;

public class MainPuntaElenaOfSavoia
	implements IReportageData
{
	public static final String EXPERIMENT_TITLE =
		"Punta Elena : graph size range : solvers competition";

	public static final String[] SETTINGS_FIELDS_NAMES = {
		"randomSeed",
		"citiesCountBeg",
		"citiesCountEnd",

		"facilitiesCountBeg",
		"facilitiesCountEnd",
		
		"eachExperimentRunsCount",

		"neighborCountBeg",
		"neighborCountRange",

		"cheapEdgeBeg",
		"cheapEdgeRange",
		"expensiveEdgeBeg",
		"expensiveEdgeRange",

		"facilityPriceBeg",
		"facilityPriceRange"
	};

	private PElenaGSCDiagramExtractor fdiaExtractor =
		new PElenaGSCDiagramExtractor();
	private ReflectionBasedSettingsContainer settingsContainer;
	private String title = EXPERIMENT_TITLE;

	public MainPuntaElenaOfSavoia() {
		PElenaGSCExperimentSettings settings =
			new PElenaGSCExperimentSettings();
		settings.initialise();

		settings.randomSeed = 4045;

		settings.citiesCountBeg = 50;
		settings.citiesCountEnd = 100;

		settings.facilitiesCountBeg = 30;
		settings.facilitiesCountEnd = 50;
		
		settings.eachExperimentRunsCount = 1;

		settings.neighborCountBeg = 10;
		settings.neighborCountRange = 5;

		settings.cheapEdgeBeg = 100;
		settings.cheapEdgeRange = 50;
		settings.expensiveEdgeBeg = 200;
		settings.expensiveEdgeRange = 100;

		settings.facilityPriceBeg = 200;
		settings.facilityPriceRange = 500;

		settings.triangleIneqEnabled = true;

		settings.validate();

//### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ###

		PEHillClimbingAlgorithmBuilder hillClimbBuilder =
			new PEHillClimbingAlgorithmBuilder();
		hillClimbBuilder.addForAllCitiesRelinkTheBest();
		hillClimbBuilder.addForChpUsflClsdFcltOpenRelikn();
		settings.solvers[2] = hillClimbBuilder.build();

//### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ###

		this.settingsContainer =
			new ReflectionBasedSettingsContainer(settings);
		settingsContainer.sortFields(SETTINGS_FIELDS_NAMES);
	}

	@Override
	public ITitlesExtractor getTitlesExtractor() {
		return fdiaExtractor;
	}

	@Override
	public IDiagramsExtractor getDiagramsExtractor() {
		return fdiaExtractor;
	}

	@Override
	public ISettingsContainer getSettingsContainer() {
		return settingsContainer;
	}

	@Override
	public String getExperimentTitle() {
		return title;
	}

	public static void main(String[] args) {
		MainPuntaElenaOfSavoia elenaA = new MainPuntaElenaOfSavoia();
		elenaA.title = "Solver-competition--Small";

		MainPuntaElenaOfSavoia elenaB = new MainPuntaElenaOfSavoia();
		PElenaGSCExperimentSettings settings =
			(PElenaGSCExperimentSettings)
				elenaB.getSettingsContainer().getSettings();
		settings.citiesCountBeg = 100;
		settings.citiesCountEnd = 300;
		settings.facilitiesCountBeg = 70;
		settings.facilitiesCountEnd = 90;
		settings.triangleIneqEnabled = false;
		elenaB.title = "Solver-competition--Big";

		MainPuntaElenaOfSavoia elenaC = new MainPuntaElenaOfSavoia();
		settings =
			(PElenaGSCExperimentSettings)
				elenaC.getSettingsContainer().getSettings();
		settings.citiesCountBeg = 100;
		settings.citiesCountEnd = 300;
		settings.facilitiesCountBeg = 90;
		settings.facilitiesCountEnd = 180;
		settings.eachExperimentRunsCount = 10;
		settings.neighborCountBeg = 20;
		settings.neighborCountRange = 10;
		elenaC.title = "Solver-competition--Large";

		LaboratoryQFront.showReportageFrame(
			EXPERIMENT_TITLE
			, elenaA
			, elenaB
			, elenaC
			, new VariateNeighborsCountReportageData()
		);
	}
}
